<template>
  <div class="page-wrapper">
    <div class="top">
      <div class="bg-img">
        <img class="img" mode="aspectFill" src="../../assets/noun-bg.png"/>
      </div>
      <div class="my-noun">
        <div class="noun-num">{{integral}}分</div>
        <div class="sub-title">我的积分</div>
      </div>
    </div>
    
    <div class="content-body">
      <div class="content-header">
        <img class="icon-noun" mode="aspectFit" src="../../assets/icon-noun.png"/>
        <div class="header-title">积分消费明细</div>
      </div>
      <div class="content-list">
        <div class="item" v-for="(item,index) in recordList" :key="index">
          <div class="order-no">
            {{item.reason}}
          </div>
          <div class="right">
            <div class="date">{{item.addTime}}</div>
            <div class="price">{{item.integral}}</div>
          </div>
        </div>
      </div>

      <!-- <loading :loadingShow.sync="loadingShow"></loading> -->
    </div>
  </div>
</template>
<script>
import { API } from '../../config'
export default {
  name:'NounRecord',
  data() {
    return{
      recordList: [],
      pageNum: 1,
      pageSize: 10,
      // loadingShow: 0,
      isLoading: false,
      integral: '',
    }
  },
  methods: {
    //获取积分总数
    getNounTotalNumber() {
      let vm = this
      let accesstoken = vm.getLocalStorage('accesstoken')
      vm.$axios.get(API + '/user/getIntegralTotal',{
          headers: {'accesstoken': accesstoken}//设置header信息
        }).then((response) => {
        if (response.data.code === 200) {
          vm.integral = response.data.data
        } else {
          vm.$message(response.data.msg)
        }
      })
    },
    getNounRecord(pageNum) {
      let vm = this
      let accesstoken = vm.getLocalStorage('accesstoken')
      vm.$axios.get(API + '/user/getIntegralDetailList?pageNum='+vm.pageNum+'&pageSize='+vm.pageSize,{headers: {'accesstoken': accesstoken}}).then((response) => {
        if (response.data.code === 200) {
          vm.recordList = response.data.data.data
          // if (vm.recordList.length < vm.pageSize) {
          //   vm.loadingShow = 0
          // } else if (res.data.data && res.data.data.length === 0) {
          //   vm.loadingShow = 2
          // } else {
          //   vm.loadingShow = 1
          // }
        } else {
          vm.$message(response.data.msg)
        }
      })
    }
  },
  mounted () {
    let vm = this
    vm.getNounTotalNumber()
    vm.getNounRecord()
  }
}
</script>

<style lang='less' scoped>
@import '../../css/user/nounRecord.less';
</style>
